//
//  Dog.m
//  block
//
//  Created by honeyrr on 2017/12/20.
//  Copyright © 2017年 honeyrr. All rights reserved.
//

#import "Dog.h"

@interface Dog()

@property(nonatomic, assign) int flag;

@end

@implementation Dog

// 2.block作为方法的参数
-(void)eat:(void (^)(NSString *))block
{
    block(@"this please have shit");
}

// 3.block作为返回值
-(void (^)(id))age
{
    return ^(id num){
        NSLog(@"%@",num);
    };
}

// 4.扩展提升
-(void (^)(NSArray *))zoos
{
    return ^(NSArray *arr) {
        [self dg:arr];
    };
}

//递归方法
-(void) dg:(NSArray *)arr
{
    NSInteger count = arr.count;
    //设置递归的出口
    if (_flag > count-1) {
        return;
    }
    self.age(arr[_flag]);
    _flag ++;
    [self dg:arr];
}
@end
